import { _decorator, Component, Node, UITransform, Widget } from 'cc';
import PageManager from './manager/PageManager';
import { PageConfig } from './comm/PageConfig';
const { ccclass, property } = _decorator;

/**
 * 场景启动后的项目入口
 * 1.初始化环境常量
 * 2.初始化日志功能
 * 3.初始化游戏参数
 * 4.打开LaunchPage
 */
@ccclass('Main')
export class Main extends Component {
    protected onLoad(): void {
        this.initRootNodes();
    }

    protected start(): void {
        PageManager.push(PageConfig.launch);
    }

    private initRootNodes() {
        const addNode = (name: string) => {
            const nd = new Node(name);
            nd.parent = this.node;
            const widget = nd.addComponent(Widget);
            widget.alignMode = Widget.AlignMode.ON_WINDOW_RESIZE;
            widget.isAlignLeft = true;
            widget.isAlignRight = true;
            widget.isAlignTop = true;
            widget.isAlignBottom = true;
            return nd;
        }
        const low = addNode('low');
        const mid = addNode('mid');
        const high = addNode('high');
        PageManager.init(low, mid, high);
    }
}


